import { api } from '@/api/common'
import { axios } from '@/utils/request'

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function login(parameter) {
  return axios({
    url: '/auth/login/yy',
    method: 'post',
    data: parameter
  })
}

export function wechatLogin() {
  return axios({
    url: api.wechatUrl,
    method: 'get'
  })
}

export function wechatBind(parameter) {
  return axios({
    url: api.wechatBind,
    method: 'post',
    data: parameter
  })
}

export function getSmsCaptcha(parameter) {
  return axios({
    url: api.SendSms,
    method: 'post',
    data: parameter
  })
}

export function register(parameter) {
  return axios({
    url: api.register,
    method: 'post',
    data: parameter
  })
}

export function changPwd(parameter) {
  return axios({
    url: api.changPwd,
    method: 'post',
    data: parameter
  })
}

export function getInfo() {
  return axios({
    url: '/system/user/info',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function logout(token) {
  return axios({
    url: '/auth/logout',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'token': token
    }
  })
}

export function switchComp(parameter) {
  return axios({
    url: '/system/accounts/switch_comp',
    method: 'get',
    params: parameter
  })
}

export function imgcode() {
  return axios({
    url: '/code',
    method: 'get',
    responseType: 'blob',
    timeout: 0,
  })
}
